package com.submit.demo.controller;

import com.submit.demo.annotation.AuthIgnore;
import com.submit.demo.common.api.CommonResult;
import com.submit.demo.service.impl.SmsCodeGenerator;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping(value="/sms")
public class SmsCodeController {
    @Autowired
    private SmsCodeGenerator smsCodeGenerator;

    @AuthIgnore
    @ApiOperation("获取验证码")
    @ResponseBody
    @RequestMapping(value = "/code", method = RequestMethod.GET)
    public CommonResult<String> generateSmsCode(HttpSession session){
        String code = smsCodeGenerator.generate(session);
        return CommonResult.success(code);
    }
}
